package com.woniuxy.portal.config.rabbit;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    /**
     * 自动生成MQ队列
     *
     * @return Queue 返回名为"email.queue"的消息队列实例
     */
    @Bean
    public Queue emailQueue() {
        return new Queue("email.queue");
    }

    /**
     * 消息序列化成JSON字符串
     *
     * @return MessageConverter 消息转换器实例，用于将消息序列化为JSON格式
     */
    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }

}
